package com.zwl.service.impl;

import java.util.List;
import java.util.Map;

import com.zwl.dao.RoleDao;
import com.zwl.dao.impl.RoleDaoImpl;
import com.zwl.po.PageBean;
import com.zwl.po.RolePo;
import com.zwl.service.RoleService;

public class RoleServiceImpl implements RoleService {
	private RoleDao roleDao=new RoleDaoImpl();

	@Override
	public List<RolePo> findByCondition(Map<String, Object> map) {
		return roleDao.findByCondition(map);
	}

	@Override
	public RolePo findbyId(Integer id) {
		return roleDao.findbyId(id);
	}

	@Override
	public int saveRoleMenu(Integer roleId, List<Integer> menuIdList) {
		roleDao.deleteRoleMenu(roleId, null);
		if(menuIdList!=null && menuIdList.size()>0){
			for(Integer menuId:menuIdList){
				roleDao.saveRoleMenu(roleId, menuId);
			}
		}
		return 1;
	}

	@Override
	public int updateRole(RolePo entity) {
		return roleDao.updateRole(entity);
	}

	@Override
	public PageBean<RolePo> findPageByCondition(int pageIndex, int pageSize, Map<String, Object> map) {
		PageBean<RolePo> pagebean=roleDao.findPageByCondition(pageIndex, pageSize, map);
		return pagebean;
	}

}
